mcurrentsens 2.2.0
Loading...
Searching...
No Matches
mCurrent Sens Click Driver

API for configuring and manipulating mCurrent Sens Click driver. More...

Topics

 mCurrent Sens Registers List
 List of registers of mCurrent Sens Click driver.
 mCurrent Sens Registers Settings
 Settings for registers of mCurrent Sens Click driver.
 mCurrent Sens MikroBUS Map
 MikroBUS pin mapping of mCurrent Sens Click driver.

Functions

void mcurrentsens_cfg_setup (mcurrentsens_cfg_t *cfg)
 mCurrent Sens configuration object setup function.
err_t mcurrentsens_init (mcurrentsens_t *ctx, mcurrentsens_cfg_t *cfg)
 mCurrent Sens initialization function.
err_t mcurrentsens_default_cfg (mcurrentsens_t *ctx)
 mCurrent Sens default configuration function.
err_t mcurrentsens_write_reg (mcurrentsens_t *ctx, uint8_t reg, uint8_t data_in)
 mCurrent Sens write register function.
err_t mcurrentsens_read_reg (mcurrentsens_t *ctx, uint8_t reg, uint8_t *data_out)
 mCurrent Sens read register function.
err_t mcurrentsens_write_regs (mcurrentsens_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 mCurrent Sens write multiple registers function.
err_t mcurrentsens_read_regs (mcurrentsens_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 mCurrent Sens read multiple registers function.
err_t mcurrentsens_write_reg16 (mcurrentsens_t *ctx, uint8_t reg, uint16_t data_in)
 mCurrent Sens write 16-bit register function.
err_t mcurrentsens_read_reg16 (mcurrentsens_t *ctx, uint8_t reg, uint16_t *data_out)
 mCurrent Sens read 16-bit register function.
err_t mcurrentsens_write_reg24 (mcurrentsens_t *ctx, uint8_t reg, uint32_t data_in)
 mCurrent Sens write 24-bit register function.
err_t mcurrentsens_read_reg24 (mcurrentsens_t *ctx, uint8_t reg, uint32_t *data_out)
 mCurrent Sens read 24-bit register function.
err_t mcurrentsens_send_fast_cmd (mcurrentsens_t *ctx, uint8_t cmd)
 mCurrent Sens send fast command function.
err_t mcurrentsens_check_com (mcurrentsens_t *ctx)
 mCurrent Sens communication check function.
err_t mcurrentsens_set_mux (mcurrentsens_t *ctx, uint8_t vin_p, uint8_t vin_n)
 mCurrent Sens set MUX function.
err_t mcurrentsens_set_gain (mcurrentsens_t *ctx, uint8_t gain)
 mCurrent Sens set gain function.
err_t mcurrentsens_set_osr (mcurrentsens_t *ctx, uint8_t osr)
 mCurrent Sens set OSR function.
err_t mcurrentsens_set_mode (mcurrentsens_t *ctx, uint8_t mode)
 mCurrent Sens set mode function.
err_t mcurrentsens_get_irq (mcurrentsens_t *ctx, uint8_t *data_out)
 mCurrent Sens get IRQ function.
err_t mcurrentsens_set_offset_cal (mcurrentsens_t *ctx, int32_t data_in)
 mCurrent Sens set offset calibration function.
err_t mcurrentsens_get_offset_cal (mcurrentsens_t *ctx, int32_t *data_out)
 mCurrent Sens get offset calibration function.
err_t mcurrentsens_set_gain_cal (mcurrentsens_t *ctx, uint32_t data_in)
 mCurrent Sens set gain calibration function.
err_t mcurrentsens_get_gain_cal (mcurrentsens_t *ctx, uint32_t *data_out)
 mCurrent Sens get gain calibration function.
err_t mcurrentsens_en_dig_cal (mcurrentsens_t *ctx, uint8_t en_offset, uint8_t en_gain)
 mCurrent Sens enable digital calibration function.
err_t mcurrentsens_apply_calib (mcurrentsens_t *ctx, mcurrentsens_calib_t cal)
 mCurrent Sens apply channel calibration function.
err_t mcurrentsens_wait_data_ready (mcurrentsens_t *ctx)
 mCurrent Sens wait data ready function.
err_t mcurrentsens_read_adc (mcurrentsens_t *ctx, int32_t *data_out)
 mCurrent Sens read ADC data function.
err_t mcurrentsens_read_adc_avg (mcurrentsens_t *ctx, uint8_t sample_count, int32_t *data_out)
 mCurrent Sens read averaged ADC function.
err_t mcurrentsens_read_voltage_avg (mcurrentsens_t *ctx, uint8_t sample_count, float *data_out)
 mCurrent Sens read averaged voltage function.
err_t mcurrentsens_read_ch1_current (mcurrentsens_t *ctx, float *data_out)
 mCurrent Sens read channel 1 current function.
err_t mcurrentsens_read_ch1_voltage (mcurrentsens_t *ctx, float *data_out)
 mCurrent Sens read channel 1 voltage function.
err_t mcurrentsens_read_ch2_current (mcurrentsens_t *ctx, float *data_out)
 mCurrent Sens read channel 2 current function.
err_t mcurrentsens_read_ch2_voltage (mcurrentsens_t *ctx, float *data_out)
 mCurrent Sens read channel 2 voltage function.
err_t mcurrentsens_read_temperature (mcurrentsens_t *ctx, float *data_out)
 mCurrent Sens read temperature function.
float mcurrentsens_adc_to_mv (int32_t adc_code, float gain_adc)
 mCurrent Sens convert ADC code to millivolts function.
void mcurrentsens_calculate_calib (mcurrentsens_calib_t *calib, float offset_coeff, float target_1, float measured_1, float target_2, float measured_2)
 mCurrent Sens calculate calibration function.
err_t mcurrentsens_write_memory (mcurrentsens_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len)
 mCurrent Sens write memory function.
err_t mcurrentsens_read_memory (mcurrentsens_t *ctx, uint8_t address, uint8_t *data_out, uint8_t len)
 mCurrent Sens read memory function.
err_t mcurrentsens_store_calib (mcurrentsens_t *ctx)
 mCurrent Sens store calibration function.
err_t mcurrentsens_fetch_calib (mcurrentsens_t *ctx)
 mCurrent Sens fetch calibration function.
uint8_t mcurrentsens_get_irq_pin (mcurrentsens_t *ctx)
 mCurrent Sens get IRQ pin function.
uint8_t mcurrentsens_get_clk_pin (mcurrentsens_t *ctx)
 mCurrent Sens get CLK pin function.

Detailed Description

API for configuring and manipulating mCurrent Sens Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ mcurrentsens_adc_to_mv()

float mcurrentsens_adc_to_mv ( int32_t adc_code,
float gain_adc )

mCurrent Sens convert ADC code to millivolts function.

This function converts signed ADC code to millivolt value.

Parameters
[in]adc_code: Signed ADC conversion code.
[in]gain_adc: ADC gain value.
Returns
Converted millivolt value.
Note
None.

◆ mcurrentsens_apply_calib()

err_t mcurrentsens_apply_calib ( mcurrentsens_t * ctx,
mcurrentsens_calib_t cal )

mCurrent Sens apply channel calibration function.

This function applies the specified channel calibration values.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]cal: Channel calibration data.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_calculate_calib()

void mcurrentsens_calculate_calib ( mcurrentsens_calib_t * calib,
float offset_coeff,
float target_1,
float measured_1,
float target_2,
float measured_2 )

mCurrent Sens calculate calibration function.

This function calculates gain and offset calibration registers based on two-point linear calibration.

Parameters
[out]calib: Calibration structure.
[in]offset_coeff: Channel coefficient.
[in]target_1: First reference value.
[in]measured_1: Measured value at first point.
[in]target_2: Second reference value.
[in]measured_2: Measured value at second point.
Returns
None.
Note
Implements linear fit equivalent to polyfit.

◆ mcurrentsens_cfg_setup()

void mcurrentsens_cfg_setup ( mcurrentsens_cfg_t * cfg)

mCurrent Sens configuration object setup function.

This function initializes Click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See mcurrentsens_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ mcurrentsens_check_com()

err_t mcurrentsens_check_com ( mcurrentsens_t * ctx)

mCurrent Sens communication check function.

This function verifies device communication by reading the RESERVED_16 register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
Returns
  • 0 - Device detected,
  • -1 - Communication error.
Note
Uses RESERVED_16 register as device ID check.

◆ mcurrentsens_default_cfg()

err_t mcurrentsens_default_cfg ( mcurrentsens_t * ctx)

mCurrent Sens default configuration function.

This function executes a default configuration of mCurrent Sens Click board.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ mcurrentsens_en_dig_cal()

err_t mcurrentsens_en_dig_cal ( mcurrentsens_t * ctx,
uint8_t en_offset,
uint8_t en_gain )

mCurrent Sens enable digital calibration function.

This function enables or disables digital offset and gain calibration.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]en_offset: Offset calibration enable setting.
[in]en_gain: Gain calibration enable setting.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_fetch_calib()

err_t mcurrentsens_fetch_calib ( mcurrentsens_t * ctx)

mCurrent Sens fetch calibration function.

This function reads calibration values from external EEPROM.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
Note
Sets calibrated flag when calibration data is valid.

◆ mcurrentsens_get_clk_pin()

uint8_t mcurrentsens_get_clk_pin ( mcurrentsens_t * ctx)

mCurrent Sens get CLK pin function.

This function reads the CLK pin logic state.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
Returns
CLK pin logic state.
Note
None.

◆ mcurrentsens_get_gain_cal()

err_t mcurrentsens_get_gain_cal ( mcurrentsens_t * ctx,
uint32_t * data_out )

mCurrent Sens get gain calibration function.

This function reads the GAINCAL register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where unsigned 24-bit gain calibration value will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_get_irq()

err_t mcurrentsens_get_irq ( mcurrentsens_t * ctx,
uint8_t * data_out )

mCurrent Sens get IRQ function.

This function reads the IRQ register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where IRQ data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_get_irq_pin()

uint8_t mcurrentsens_get_irq_pin ( mcurrentsens_t * ctx)

mCurrent Sens get IRQ pin function.

This function reads the IRQ pin logic state.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
Returns
IRQ pin logic state.
Note
None.

◆ mcurrentsens_get_offset_cal()

err_t mcurrentsens_get_offset_cal ( mcurrentsens_t * ctx,
int32_t * data_out )

mCurrent Sens get offset calibration function.

This function reads the OFFSETCAL register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where signed 24-bit offset calibration value will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_init()

err_t mcurrentsens_init ( mcurrentsens_t * ctx,
mcurrentsens_cfg_t * cfg )

mCurrent Sens initialization function.

This function initializes all necessary pins and peripherals used for this Click board.

Parameters
[out]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See mcurrentsens_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ mcurrentsens_read_adc()

err_t mcurrentsens_read_adc ( mcurrentsens_t * ctx,
int32_t * data_out )

mCurrent Sens read ADC data function.

This function reads the signed 24-bit ADC conversion data.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where ADC data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_adc_avg()

err_t mcurrentsens_read_adc_avg ( mcurrentsens_t * ctx,
uint8_t sample_count,
int32_t * data_out )

mCurrent Sens read averaged ADC function.

This function reads multiple ADC samples and returns averaged data.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]sample_count: Number of samples.
[out]data_out: Pointer to memory location where averaged ADC data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
First sample is discarded.

◆ mcurrentsens_read_ch1_current()

err_t mcurrentsens_read_ch1_current ( mcurrentsens_t * ctx,
float * data_out )

mCurrent Sens read channel 1 current function.

This function reads channel 1 current measurement in mA.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where ADC data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_ch1_voltage()

err_t mcurrentsens_read_ch1_voltage ( mcurrentsens_t * ctx,
float * data_out )

mCurrent Sens read channel 1 voltage function.

This function reads channel 1 voltage measurement in mV.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where ADC data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_ch2_current()

err_t mcurrentsens_read_ch2_current ( mcurrentsens_t * ctx,
float * data_out )

mCurrent Sens read channel 2 current function.

This function reads channel 2 current measurement in mA.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where ADC data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_ch2_voltage()

err_t mcurrentsens_read_ch2_voltage ( mcurrentsens_t * ctx,
float * data_out )

mCurrent Sens read channel 2 voltage function.

This function reads channel 2 voltage measurement in mV.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where ADC data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_memory()

err_t mcurrentsens_read_memory ( mcurrentsens_t * ctx,
uint8_t address,
uint8_t * data_out,
uint8_t len )

mCurrent Sens read memory function.

This function reads a sequence of bytes from the device memory over I2C, starting at the selected 8-bit address. The read length must not exceed the page size (16 bytes) and the transfer must not cross the device end address.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]address: Start memory address (8-bit).
[out]data_out: Pointer to output data buffer.
[in]len: Number of bytes to read (max page size).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ mcurrentsens_read_reg()

err_t mcurrentsens_read_reg ( mcurrentsens_t * ctx,
uint8_t reg,
uint8_t * data_out )

mCurrent Sens read register function.

This function reads a byte from the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Pointer to memory location where data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_reg16()

err_t mcurrentsens_read_reg16 ( mcurrentsens_t * ctx,
uint8_t reg,
uint16_t * data_out )

mCurrent Sens read 16-bit register function.

This function reads two bytes from the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Pointer to memory location where data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_reg24()

err_t mcurrentsens_read_reg24 ( mcurrentsens_t * ctx,
uint8_t reg,
uint32_t * data_out )

mCurrent Sens read 24-bit register function.

This function reads three bytes from the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Pointer to memory location where data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_read_regs()

err_t mcurrentsens_read_regs ( mcurrentsens_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

mCurrent Sens read multiple registers function.

This function reads multiple bytes starting from the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Pointer to output buffer.
[in]len: Number of bytes to read.
Returns
  • 0 - Success,
  • -1 - Error.
Note
Uses incremental read command.

◆ mcurrentsens_read_temperature()

err_t mcurrentsens_read_temperature ( mcurrentsens_t * ctx,
float * data_out )

mCurrent Sens read temperature function.

This function reads internal temperature data.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[out]data_out: Pointer to memory location where temperature data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
Temperature data is returned in degrees Celsius.

◆ mcurrentsens_read_voltage_avg()

err_t mcurrentsens_read_voltage_avg ( mcurrentsens_t * ctx,
uint8_t sample_count,
float * data_out )

mCurrent Sens read averaged voltage function.

This function reads ADC samples and converts them to millivolts.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]sample_count: Number of samples.
[out]data_out: Pointer to memory location where voltage data will be stored.
Returns
  • 0 - Success,
  • -1 - Error.
Note
Uses internal reference and ADC gain.

◆ mcurrentsens_send_fast_cmd()

err_t mcurrentsens_send_fast_cmd ( mcurrentsens_t * ctx,
uint8_t cmd )

mCurrent Sens send fast command function.

This function sends a fast command to the device.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]cmd: Fast command byte.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_set_gain()

err_t mcurrentsens_set_gain ( mcurrentsens_t * ctx,
uint8_t gain )

mCurrent Sens set gain function.

This function sets the programmable gain amplifier value.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]gain: Gain setting.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_set_gain_cal()

err_t mcurrentsens_set_gain_cal ( mcurrentsens_t * ctx,
uint32_t data_in )

mCurrent Sens set gain calibration function.

This function writes the GAINCAL register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]data_in: Unsigned 24-bit gain calibration value.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_set_mode()

err_t mcurrentsens_set_mode ( mcurrentsens_t * ctx,
uint8_t mode )

mCurrent Sens set mode function.

This function sets the ADC operating mode.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]mode: ADC operating mode setting.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_set_mux()

err_t mcurrentsens_set_mux ( mcurrentsens_t * ctx,
uint8_t vin_p,
uint8_t vin_n )

mCurrent Sens set MUX function.

This function selects the positive and negative ADC input channels.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]vin_p: Positive ADC input channel.
[in]vin_n: Negative ADC input channel.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_set_offset_cal()

err_t mcurrentsens_set_offset_cal ( mcurrentsens_t * ctx,
int32_t data_in )

mCurrent Sens set offset calibration function.

This function writes the OFFSETCAL register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]data_in: Signed 24-bit offset calibration value.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_set_osr()

err_t mcurrentsens_set_osr ( mcurrentsens_t * ctx,
uint8_t osr )

mCurrent Sens set OSR function.

This function sets the oversampling ratio.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]osr: Oversampling ratio setting.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_store_calib()

err_t mcurrentsens_store_calib ( mcurrentsens_t * ctx)

mCurrent Sens store calibration function.

This function stores calibration values to external EEPROM.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
Note
Stores calibration data in two EEPROM pages.

◆ mcurrentsens_wait_data_ready()

err_t mcurrentsens_wait_data_ready ( mcurrentsens_t * ctx)

mCurrent Sens wait data ready function.

This function waits until ADC conversion is complete.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
Returns
  • 0 - Data ready,
  • -1 - Timeout.
Note
Uses IRQ pin and DR_STATUS flag.

◆ mcurrentsens_write_memory()

err_t mcurrentsens_write_memory ( mcurrentsens_t * ctx,
uint8_t address,
uint8_t * data_in,
uint8_t len )

mCurrent Sens write memory function.

This function writes a sequence of bytes to the device memory over I2C, starting at the selected 8-bit address. The write length must not exceed the page size (16 bytes) and the transfer must not cross the device end address.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]address: Start memory address (8-bit).
[in]data_in: Pointer to input data buffer.
[in]len: Number of bytes to write (max page size).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ mcurrentsens_write_reg()

err_t mcurrentsens_write_reg ( mcurrentsens_t * ctx,
uint8_t reg,
uint8_t data_in )

mCurrent Sens write register function.

This function writes a byte to the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_write_reg16()

err_t mcurrentsens_write_reg16 ( mcurrentsens_t * ctx,
uint8_t reg,
uint16_t data_in )

mCurrent Sens write 16-bit register function.

This function writes two bytes to the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: 16-bit data to be written.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_write_reg24()

err_t mcurrentsens_write_reg24 ( mcurrentsens_t * ctx,
uint8_t reg,
uint32_t data_in )

mCurrent Sens write 24-bit register function.

This function writes three bytes to the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: 24-bit data to be written.
Returns
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ mcurrentsens_write_regs()

err_t mcurrentsens_write_regs ( mcurrentsens_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

mCurrent Sens write multiple registers function.

This function writes multiple bytes starting from the specified register.

Parameters
[in]ctx: Click context object. See mcurrentsens_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Pointer to data buffer.
[in]len: Number of bytes to write.
Returns
  • 0 - Success,
  • -1 - Error.
Note
Uses incremental write command.